class Scheduler2 {
    constructor(limit) {
        this.limit = limit
        this.taskPoll = []
    }
    addTask(promiseCreate){
        return new Promise((reslove,reject) => {
            this.taskPoll.push(async () => {
                await promiseCreate()
                reslove()
            })
        })
    }
    start(){
        while(this.limit-->0){
            this.next()
        }
    }
    async next(){
        if(this.taskPoll.length){
            await this.taskPoll.shift()();
            this.next()
        }
    }
}